<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>健身房管理系统</title>
  <link rel="stylesheet" type="text/css" href="./static/layui/css/layui.css" />

</head>

<body>
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo layui-hide-xs layui-bg-blue">健身房管理系统</div>
      <!-- 头部区域（可配合layui 已有的水平导航） -->
      <ul class="layui-nav layui-layout-left">
        <!-- 移动端显示 -->
        <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
          <i class="layui-icon layui-icon-spread-left"></i>
        </li>

      </ul>
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item layui-hide layui-show-md-inline-block">
          <a href="javascript:;">
            <img id="userHeader" src="http://rued9prih.hn-bkt.clouddn.com/FoOp9CxNmERSrimeQjp8MgFxagw-" class="layui-nav-img">
            <h id="userInfo">未登录</h>
          </a>
          <dl class="layui-nav-child">
            <dd><a lay-href="./views/accountManagement.html" class="layui-btn">修改个人信息</a></dd>
            <dd><a href="" id="uploadHeader" class="layui-btn"><i class="layui-icon">&#xe67c;</i>修改头像</a></dd>
            <a id="out" href="views/login.html" class="layui-btn"><dd>登出</dd></a>
          </dl>
        </li>
        <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
          <a href="javascript:;">
            <i class="layui-icon layui-icon-more-vertical"></i>
          </a>
        </li>
      </ul>
    </div>

    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-home"></i>&nbsp;&nbsp;首页</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="./views/home.html">首页</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-date"></i>&nbsp;&nbsp;系统账号管理</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="./views/accountManagement.html">账号管理</a></dd>
              <dd><a lay-href="./views/accountAdd.html">新增账号</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-service"></i>&nbsp;&nbsp;会员信息管理</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="./views/memberManagement.html">会员管理</a></dd>
              <dd><a lay-href="./views/memberAdd.html">新增会员</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-tips"></i>&nbsp;&nbsp;付费项目管理</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="views/payprojectManagement.html">所有项目管理</a></dd>
              <dd><a lay-href="views/payprojectAdd.html">新增项目</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-form"></i>&nbsp;&nbsp;所有教练管理</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="./views/Coach.html">查看/编辑教练</a></dd>
              <dd><a lay-href="./views/addCoach.html">新增</a></dd>
            </dl>
          </li>
          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-email"></i>&nbsp;&nbsp;健身课程管理</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="views/Course.html">查看/编辑课程</a></dd>
              <dd><a lay-href="views/addCourse.html">新增</a></dd>
            </dl>
          </li>

          <li class="layui-nav-item">
            <a lay-href="javascript:;"><i class="layui-icon layui-icon-set"></i>&nbsp;&nbsp;设置</a>
            <dl class="layui-nav-child">
              <dd><a lay-href="javascript:;">组织管理</a></dd>
              <dd><a lay-href="accountManagement.html">账号管理</a></dd>
              <dd><a lay-href="javascript:;">角色管理</a></dd>
              <dd><a lay-href="javascript:;">系统日志</a></dd>
              <dd><a lay-href="javascript:;">数据字典管理</a></dd>
            </dl>
          </li>
        </ul>
      </div>
    </div>

    <div class="layui-body">
      <!-- 内容主体区域 -->
      <!-- <div style="padding: 15px;">内容主体区域。记得修改 layui.css 和 js 的路径</div> -->
      <!-- 临时src，页面开发完记得删除 -->
      <iframe id="iframeMain" style="padding: 15px;" src="./views/home.html" frameborder="0" width="95%"
        height="100%"></iframe>
    </div>

    <div class="layui-footer">
      第六组——健身房管理系统
    </div>
  </div>


<!--  <script>-->
<!--    $('userInfo').innerText = sessionStorage.getItem(user)-->
<!--  </script>-->

  <script src="./static/layui/layui.js" charset="UTF-8"></script>
  <script src="./static/js/jquery1.11.13.js" charset="UTF-8"></script>
  <script>


    //JS 
    layui.use(['element', 'layer', 'util','upload'], function () {
      var element = layui.element
        , layer = layui.layer
        , util = layui.util
        , $ = layui.$;

      //上传头像
      var upload = layui.upload;
      var uploadInst = upload.render({
            elem: '#uploadHeader' //绑定元素
            ,accept: 'imges'
            ,field:'img'
            ,exts:'jpg|png|jpeg'  //允许上传的图片后缀
            ,auto: true   //自动上传
            ,url: 'http://localhost:8181/user/upload' //上传接口
            ,done: function(res){
              //上传完毕回调
              $('#userHeader').attr('src',res.data);

            }
            ,error: function(){
              //请求异常回调
             console.log("头像url："+res.data)
            }
          });


      //头部事件
      util.event('lay-header-event', {
        //左侧菜单事件
        menuLeft: function (othis) {
          layer.msg('展开左侧菜单的操作', { icon: 0 });
        }
        , menuRight: function () {
          layer.open({
            type: 1
            , content: '<div style="padding: 15px;">处理右侧面板的操作</div>'
            , area: ['260px', '100%']
            , offset: 'rt' //右上角
            , anim: 5
            , shadeClose: true
          });
        }
      });

    });

    $(document).ready(function () {
      //点击dd标签下的a标签，将其herf中的值设置给id为iframeMain的iframe标签的src，实现页面嵌套跳转
      $("dd>a").click(function (e) {
        e.preventDefault();
        $("#iframeMain").attr("src", $(this).attr("lay-href")); //iframeMain是主页面iframe的id
      });
    });
  </script>

<!--  显示用户名-->
  <script type="text/javascript">
    var user = sessionStorage.getItem("user");
    // 找到要渲染数据的元素
    var userInfo = document.getElementById("userInfo");

    // 将JSON字符串转化为JavaScript对象
    var userJson = JSON.parse(user);

    // 将数据添加到元素中
    userInfo.innerHTML = userJson.username;

  </script>


</body>

</html>